<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script type="text/javascript">
        window.onload =function () {
            del = document.getElementsByClassName('del');

            for (var i = 0; i < del.length; i++) {
                del[i].onclick = function () {
                    // this.style.background="red"
                    // this.parentNode.parentNode.parentNode.parentNode.style.background="red"
                    this.nextSibling.nextSibling.style.background="red"
                }
            }

            title =  document.getElementById('title');

            title.lastChild.style.background="red"
        }
    </script>
</head>
<body>
    <table border="1">
        <tr id="title">
            <td>姓名</td>
            <td>年龄</td>
            <td>操作</td></tr>
        <tr>
            <td>小明</td>
            <td>小明</td>
            <td class='del'>删除</td>
        </tr>
        <tr>
            <td>小明</td>
            <td>小明</td>
            <td class='del'>删除</td>
            <td>xxx</td>
        </tr>
        <tr>
            <td>小明</td>
            <td>小明</td>
            <td class='del'>删除</td>
        </tr>
        <tr>
            <td>小明</td>
            <td>小明</td>
            <td class='del'>删除</td>
        </tr>
    </table>
</body>
</html>